home *** CD-ROM | disk | FTP | other *** search
/ MacHack 2001 / MacHack 2001.toast / pc / The Hacks / APLocation / Sources / MacOS_UAppleEventTraits.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-06-23  |  2.9 KB  |  102 lines

  1. /*==================================================================
  2.     File:        MacOS_UAppleEventTraits.h
  3.     
  4.     Contains:    Apple Event descriptor trait declarations for use
  5.                 with the Apple Event utility classes.
  6.  
  7.     Written by:    Ed Reed
  8.     
  9.     Copyright:    © 1999 Connectix Corporation
  10. ==================================================================*/
  11.  
  12. #pragma once
  13.  
  14. #ifndef __AEDATAMODEL__
  15. #include <AEDataModel.h>
  16. #endif
  17.  
  18. #ifndef __AEOBJECTS__
  19. #include <AEObjects.h>
  20. #endif
  21.  
  22. #ifndef __AEREGISTRY__
  23. #include <AERegistry.h>
  24. #endif
  25.  
  26. #ifndef __ERRORS__
  27. #include <Errors.h>
  28. #endif
  29.  
  30. #ifndef __EPPC__
  31. #include <EPPC.h>
  32. #endif
  33.  
  34. #ifndef __PROCESSES__
  35. #include <Processes.h>
  36. #endif
  37.  
  38. /*******************************************************************
  39.     TYPE/CLASS DEFINTIONS
  40. *******************************************************************/
  41.  
  42. /*------------------------------------------------------------------
  43.     AEDescriptorTraits
  44. ------------------------------------------------------------------*/
  45.  
  46. // Generic template
  47. template <typename _Type>
  48. class AEDescriptorTraits
  49. {
  50. public:
  51.     static Size GetMaxSize(void) { return sizeof(_Type); }
  52. };
  53.  
  54. // Specializations for common AE descriptor types
  55. #define DeclareAEDescriptorTrait_(_Type, _Code)                                    \
  56. template <>                                                                        \
  57. class AEDescriptorTraits<_Type>                                                    \
  58. {                                                                                \
  59. public:                                                                            \
  60.     enum { kDescriptorType = _Code };                                            \
  61.     static Size GetSize(const _Type & /* inValue */) { return sizeof(_Type); }    \
  62.     static Size GetMaxSize(void) { return sizeof(_Type); }                        \
  63. }
  64.  
  65. DeclareAEDescriptorTrait_(Boolean,                typeBoolean);
  66. DeclareAEDescriptorTrait_(SInt16,                typeSInt16);
  67. DeclareAEDescriptorTrait_(SInt32,                typeSInt32);
  68. DeclareAEDescriptorTrait_(FourCharCode,            typeEnumeration);
  69. DeclareAEDescriptorTrait_(SInt64,                typeSInt64);
  70. DeclareAEDescriptorTrait_(Float32,                typeIEEE32BitFloatingPoint);
  71. DeclareAEDescriptorTrait_(Float64,                typeIEEE64BitFloatingPoint);
  72. DeclareAEDescriptorTrait_(ProcessSerialNumber,    typeProcessSerialNumber);
  73. DeclareAEDescriptorTrait_(FSSpec,                typeFSS);
  74. DeclareAEDescriptorTrait_(Point,                typeQDPoint);
  75. DeclareAEDescriptorTrait_(Rect,                    typeQDRectangle);
  76.  
  77. #if !TARGET_API_MAC_CARBON                // not supported in Carbon
  78. DeclareAEDescriptorTrait_(TargetID,                typeTargetID);
  79. #endif
  80.  
  81. // Disallow automatic template instantiation for the following types
  82. #define DeclareBogusAEDescriptorTrait_(_Type)                                    \
  83. template <>                                                                        \
  84. class AEDescriptorTraits<_Type>                                                    \
  85. {                                                                                \
  86. }
  87.  
  88. /*==================================================================
  89.     Change History (most recent first):
  90.  
  91.     $Log: MacOS_UAppleEventTraits.h,v $
  92.     Revision 1.3  2001/03/05 23:41:51  mfoley
  93.     Conditionally removed the TargetID trait - it's not supported for Carbon.
  94.     
  95.     Revision 1.2  1999/04/23 22:08:32  reed
  96.     Added TargetID descriptor trait
  97.     
  98.     Revision 1.1  1999/04/12 20:16:03  reed
  99.     First Checked In.
  100.     
  101. ==================================================================*/
  102.